/**
 * Section Nav
 */

// -------- Main Component --------
.section-nav {
	position: relative;
	width: 100%;
	padding: 0;
	margin: 0 0 17px 0;
	background: $white;
	box-sizing: border-box;
	box-shadow: 0 0 0 1px transparentize( lighten( $gray, 20% ), .5 ),
		0 1px 2px lighten( $gray, 30% );

	&.is-empty .section-nav__panel {
		visibility: hidden;
	}

	@include breakpoint( "<480px" ) {
		&.is-open {
			box-shadow: 0 0 0 1px $gray,
				0 2px 4px lighten( $gray, 20 );
		}
	}

	@include breakpoint( ">480px" ) {
		&.has-pinned-items {
			padding-right: 60px;
		}
	}

	@include breakpoint( "480px-660px" ) {
		&.has-pinned-items {
			padding-right: 50px;
		}
	}

	@include breakpoint( "<660px" ) {
		margin-bottom: 9px;
	}
}

// -------- Mobile Specific Header / Panel --------
.section-nav__mobile-header {
	display: flex;
	padding: 15px;
	font-size: 14px;
	line-height: 16px;
	color: $gray-dark;
	font-weight: 600;
	cursor: pointer;

	&:after {
		@include noticon( '\f431', 20px );
		line-height: 16px;
		color: rgba( $gray, 0.5 );
	}

	.section-nav.is-open & {
		&:after {
			content: '\f432';
		}
	}

	.section-nav.has-pinned-items & {
		padding-right: 50px;

		&:after {
			margin-left: 8px;
		}
	}

	@include breakpoint( ">480px" ) {
		display: none;
	}
}

.section-nav__mobile-header-text {
	width: 0;
	flex: 1 0 auto;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;

	small {
		margin-left: 5px;
		font-size: 11px;
		color: $gray;
		font-weight: 600;
		text-transform: uppercase;
	}

	.section-nav.has-pinned-items & {
		width: auto;
		flex: 0 1 auto;
	}
}

.section-nav__panel {
	box-sizing: border-box;
	width: 100%;

	@include breakpoint( "<480px" ) {
		.section-nav.is-open & {
			padding-bottom: 15px;
			border-top: solid 1px lighten( $gray, 20% );
			background: linear-gradient(to bottom, $gray-light 0%, $white 4px);
		}
	}

	@include breakpoint( ">480px" ) {
		display: flex;
		align-items: center;

		&:first-child {
			width: 0;
			flex: 1 0 auto;
		}
	}
}

.section-nav-group {
	position: relative;
	margin-top: 16px;
	padding-top: 16px;
	border-top: solid 1px lighten( $gray, 20% );

	&:first-child {
		padding-top: 0;
		border-top: none;
	}

	@include breakpoint( "<480px" ) {
		display: none;

		.section-nav.is-open & {
			display: block;
		}
	}

	@include breakpoint( ">480px" ) {
		margin-top: 0;
		padding-top: 0;
		border-top: none;

		&:first-child {
			display: flex;
			width: 0;
			flex: 1 0 auto;
		}
	}
}

.section-nav__button {
	width: 100%;
	margin-top: 24px;
}

.section-nav__hr {
	background: lighten( $gray, 30 );
}

// -------- Labels --------
// used above nav group < 480px with sibling control groups
.section-nav-group__label {
	display: none;
	margin-bottom: 8px;
	padding: 0 15px;
	font-size: 11px;
	color: $gray;
	font-weight: 600;
	text-transform: uppercase;
	line-height: 12px;

	@include breakpoint( "<480px" ) {
		.has-siblings & {
			display: block;
		}
	}
}

.section-nav-group__label-text {
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}

// -------- Nav Items --------
.section-nav-tab .count {
	margin-left: 8px;
}

// -------- Nav Tabs --------
// which contain items
.section-nav-tabs {
	@include breakpoint( ">480px" ) {
		width: 0;
		flex: 1 0 auto;

		&.is-dropdown {
			position: relative;
			width: auto;
			flex: 0 1 auto;
			margin: 8px;
		}
	}
}

// -------- Nav Tabs - inline list --------
.section-nav-tabs__list {
	margin: 0;
	list-style: none;

	@include breakpoint( ">480px" ) {
		display: flex;
		width: 100%;
		overflow: hidden;

		.is-dropdown & {
			display: none;
		}
	}
}

// -------- Nav Tabs - individual tab --------
.section-nav-tab {
	@include breakpoint( ">480px" ) {
		width: auto;
		flex: none;
		border-bottom: 2px solid transparent;
		border-top: none;
		text-align: center;

		&.is-selected {
			border-bottom-color: $gray-dark;
		}
	}
}

.section-nav-tab__link,
.section-nav-tab__text {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.section-nav-tab__link {
	display: flex;
	align-items: center;
	box-sizing: border-box;
	padding: 15px;
	width: 100%;
	font-size: 14px;
	font-weight: 600;
	line-height: 18px;
	color: $gray-dark;
	cursor: pointer;

	&:visited {
		color: $gray-dark;
	}

	&[disabled],
	.notouch &[disabled]:hover {
		color: lighten( $gray, 30% );
		cursor: default;
	}

	.is-selected & {
		color: $white;
		background-color: $blue-medium;

		@include breakpoint( "<480px" ) {
			.count {
				color: $white;
				border-color: $white;
			}
		}
	}

	&:focus {
		outline: none;
		.accessible-focus & {
			outline: solid $gray 1px;
		}
	}

	.is-external & {
		&:after {
			@include noticon('\f442');
			font-size: 18px;
			padding-left: 2px;
		}
	}

	.notouch & {
		&:hover {
			color: $blue-medium;
		}
	}

	.notouch .is-selected & {
		&:hover {
			color: $white;
		}
	}

	@include breakpoint( ">480px" ) {
		display: block;
		width: auto;
		padding: 16px 16px 14px 16px;
		color: $blue-wordpress;
		font-weight: 400;

		&:visited {
			color: $blue-wordpress;
		}

		.is-selected & {
			color: $gray-dark;
			background-color: transparent;

			&:after {
				display: none;
			}
		}

		.notouch .is-selected & {
			&:hover {
				color: $gray-dark;
			}
		}
	}
}

.section-nav-tab__text {
	display: block;
	flex: 1 0 auto;
	width: 0;
	color: inherit;

	@include breakpoint( ">480px" ) {
		display: inline;
		flex: none;
		width: auto;
	}
}

// -------- Nav Tabs - dropdowns --------
.section-nav-tabs__dropdown {
	position: relative;
	z-index: z-index( 'section-nav-tabs__dropdown-parent', '.section-nav-tabs__dropdown' );
	width: 100%;

	&.is-open {
		z-index: z-index( 'section-nav-tabs__dropdown-parent', '.section-nav-tabs__dropdown.is-open' );
	}

	.select-dropdown__container {
		max-width: 200px;
		position: static;
	}
}

// -------- Nav Segmented Control --------
.section-nav__segmented {

	.segmented-control {
		margin: 0 15px;
	}

	.segmented-control__link {
		padding: 3px 16px 5px;
	}
}

// -------- Search --------
.section-nav {
	.search {
		overflow: hidden;
	}
	@include breakpoint( "<480px" ) {
		.search.is-expanded-to-container {
			height: 46px;
		}
	}
}
